<template>
  <div>
    <a-table :columns="columns" :data-source="data" rowKey="id" :pagination="false">
      <span slot="createTime" slot-scope="text">
        <span>{{text | dateFilter}}</span>
      </span>
      <span slot="statusDesc" slot-scope="text">
        <a-badge :status="text == '未完成' ? 'error' : 'success'" :text="text" />
      </span>
      <span slot="total" slot-scope="text, record">
        <span>共{{text}}条数据,成功{{record.success ? record.success : 0}}条,失败{{record.fail ? record.fail : 0}}条</span>
      </span>
      <span slot="opera" slot-scope="text, record">
        <a :href="record.sourceFileUrl" :disabled="record.sourceFileUrl ? false : true">下载上传文件</a>
        <a-divider type="vertical" />
        <a :href="record.failFileUrl" :disabled="record.failFileUrl ? false : true">下载失败文件</a>
      </span>
    </a-table>
  </div>
</template>

<script>
import datas from "@/utils/data";
import { transferDate } from '@/utils/util'
import { getLatestImportHistoryRecordApi } from '@/services/employeeManage'

export default {
  name: "tabs3",
  data () {
    return {
      columns: datas.importHistoryColumn,
      data: [],
    };
  },
  created () {
    this.getData()
  },
  filters: {
    dateFilter (val) {
      return transferDate(val, 0)
    }
  },
  methods: {
    getData () {
      getLatestImportHistoryRecordApi().then(res => {
        let { code, data } = res.data
        if (code === 200) {
          this.data = data
        }
      })
    }
  },
};
</script>

<style scoped>
.txt_span {
  position: relative;
}
</style>
